
module.exports = {
  searchSeckill: (req,res,data,err) => {
    let qeuryl = req.query
    let resData = JSON.parse(data)
    if (qeuryl && qeuryl.value) {
      switch (qeuryl.value) {
        case 'ms':
          resData.data = resData.data.filter(item => item.miaosha)
        break;
        case 'kj':
          resData.data = resData.data.filter(item => item.kanjia)
        break;
        default:
          resData = resData
      }
      res.writeHead(200, { "Content-Type" : "text/html;charset=utf-8" })
      res.end(JSON.stringify(resData))
    } else if (qeuryl && qeuryl.categoryId ) {
      resData.data = resData.data.filter(item => item.categoryId == qeuryl.categoryId)
      res.writeHead(200, { "Content-Type" : "text/html;charset=utf-8" })
      res.end(JSON.stringify(resData))
    }  else if (qeuryl && qeuryl.recommendStatus) {
      resData.data = resData.data.filter(item => item.recommendStatus == qeuryl.recommendStatus)
      res.writeHead(200, { "Content-Type" : "text/html;charset=utf-8" })
      res.end(JSON.stringify(resData))
    } else {
      res.writeHead(200, { "Content-Type" : "text/html;charset=utf-8" })
      res.end(data)
    }
  }
}